﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
/*For diagnostics*/
using System.Diagnostics;
/*Used for XML serialization*/
using System.IO;
using System.Xml;
using System.Xml.Serialization;
/*Used for network communication*/
using System.Net;
using System.Net.Sockets;
/*Used for threading applications*/
using System.Threading;


namespace Simple_RCU
{
    public partial class RCUForm : Form
    {
        Receiver receiver;
        Thread receiverThread;

        public RCUForm()
        {
            InitializeComponent();
        }

        private void RCUForm_Load(object sender, EventArgs e)
        {
            try
            {
                System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
                receiver = new Receiver(11000);
                receiverThread = new Thread(new ThreadStart(receiver.Receive));
                receiverThread.Start();
                statusLabel.Visible = true;
            }
            catch (Exception ex)
            {
                Application.Exit();
            }
        }

        void Application_ApplicationExit(object sender, EventArgs e)
        {
            /*on exit, close receiver if it exists*/
            if (receiver != null)
                receiver.Stop();
        }
    }
}
